
export const crudOptions = vm => {
  return {
    pageOptions: {
      compact: true
    },
    options: {
      tableType: 'vxe-table',
      rowKey: true, // 必须设置，true or false
      rowId: 'id',
      height: '100%', // 表格高度100%, 使用toolbar必须设置
      highlightCurrentRow: false
    },
    rowHandle: {
      width: 140,
      view: {
        thin: true,
        text: '',
        show: false,
      },
      edit: {
        thin: true,
        text: '',
        disabled () {
          return !vm.hasPermissions('Update')
        }
      },
      remove: {
        thin: true,
        text: '',
        disabled () {
          return !vm.hasPermissions('Delete')
        }
      },
      custom: [
        {
          thin: true,
          text: '',
          title: '绘制围栏',
          size: 'small',
          type: 'warning',
          icon: 'el-icon-printer',
          show: true,
          emit: 'drawFence'
        }
      ]
    },
    indexRow: {
      // 或者直接传true,不显示title，不居中
      title: '序号',
      align: 'center',
      width: 100
    },
    viewOptions: {
      componentType: 'form'
    },
    formOptions: {
      defaultSpan: 24, // 默认的表单 span
      width: '35%'
    },
    columns: [{
      title: 'ID',
      key: 'id',
      show: false,
      disabled: true,
      width: 90,
      form: {
        disabled: true
      }
    },
    {
      title: '围栏名称',
      key: 'search',
      show: false,
      disabled: true,
      search: {
        disabled: false
      },
      form: {
        disabled: true,
        component: {
          placeholder: '请输入围栏名称'
        }
      },
      view: {
        disabled: true
      }
    },
    {
      title: '围栏名称',
      key: 'fence_name',
      treeNode: true,
      type: 'input',
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: '围栏名称必填' }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: '请输入围栏名称'
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: '围栏类型',
      key: 'fence_alarm_type',
      type: 'select',
      search: {
        disabled: false
      },
      dict: {
        data: [{ value: "out", label: '驶离' }, { value: "in", label: '驶入' }]
      },
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: '围栏类型必填' }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: '请输入围栏类型'
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: '围栏状态',
      key: 'status',
      type: 'select',
      search: {
        disabled: false
      },
      dict: {
        data: [{ value: 0, label: '开启' }, { value: 1, label: '关闭' }]
      },
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: '围栏状态必填' }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: '请输入围栏状态'
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    }
    ].concat(vm.commonEndColumns({ update_datetime: { showForm: false, showTable: false }, create_datetime: { showForm: false, showTable: true } }))
  }
}
